layui.config({
	base : "js/"
}).use(['form','layer','jquery','layedit','laydate'],function(){
	var form = layui.form(),
		layer = parent.layer === undefined ? layui.layer : parent.layer,
		laypage = layui.laypage,
		layedit = layui.layedit,
		laydate = layui.laydate,
		$ = layui.jquery;

	//创建一个编辑器
 	var editIndex = layedit.build('news_content');
 	var addNewsArray = [],addNews;
 	
 	var orgId = window.sessionStorage.getItem("organizeId");

 	
 	form.on("submit(subInfo)",function(data){
 		layedit.sync(editIndex);
 		var data ={
 			account:$(".account").val(),
 			orgId:orgId
 		}
 		//弹出loading
        addInfo(data,function(){
			setTimeout(function(){
				layer.closeAll("iframe");
				parent.location.reload();
			},2000)
        })
 		return false;
 	})
	
})
function addInfo(data,callback) {
    $.ajax({
        url: $.httpRootPath()+'/api/web/manager/i/'+data.orgId+'/org',
        type: 'POST',
        dataType: 'json',
        data: data,
        timeout: 15000,
        cache: false,
        success: function (r) {
            if (r.code == "00") {
              	layer.msg("添加成功！");
            } else {
               layer.msg(r.msg);
               return;
            }
            callback();
        },
        error: function (e) {
          layer.msg("系统错误！");
        },
        complete:function(){
        	
        }
    });

}




